import { createRouter, createWebHistory } from 'vue-router'
import NProgress from '@/config/nprogress.js'

const router = createRouter({
  history: createWebHistory(import.meta.env.BASE_URL),
  routes: [
    {
      path: '/',
      redirect: '/login',
      name:'index',
      component:() => import('@/views/common/index.vue'),
      children:[
        {
          path:'login',
          name:"login",
          component:()=>import('@/views/common/views/login/index.vue')
        }
      ]
    },
    {
      path: '/manager',
      name: 'home',
      component: () => import('../views/manager/home/index.vue'),
      redirect: '/manager/statistics',
      children: [
        {
          path: 'statistics',
          name: 'statistics',
          component: () => import('../views/manager/statistics/index.vue'),
        },
        {
          path: 'user',
          name: 'user',
          component: () => import('../views/manager/user/index.vue'),
        },
        {
          path: 'tips',
          name: 'tips',
          component: () => import('../views/manager/tips/index.vue'),
        },
        {
          path: 'manual',
          name: 'manual',
          component: () => import('@/views/manager/manual/index.vue'),
        },
        {
          path: 'plant',
          name: 'plant',
          component: () => import('@/views/manager/plant/index.vue'),
        },
        {
          path: 'plate',
          name: 'plate',
          component: () => import('@/views/manager/plate/index.vue'),
        },
        {
          path: 'post',
          name: 'post',
          component: () => import('@/views/manager/post/index.vue'),
        },
        {
          path: 'collect',
          name: 'collect',
          component: () => import('@/views/manager/collect/index.vue'),
        },
        {
          path: 'comment',
          name: 'comment',
          component: () => import('@/views/manager/comment/index.vue'),
        },
        {
          path: 'center',
          name: 'center',
          component: () => import('@/views/manager/center/index.vue'),
        },
        {
          path: 'password',
          name: 'password',
          component: () => import('@/views/manager/change-password/index.vue'),
        },
      ],
    }
  ],
})

router.beforeEach((to, from, next) => {
  NProgress.start()
  next()
})

router.afterEach(() => {
  NProgress.done()
})
export default router
